import java.util.ArrayList;

/**
 * 
 * @author Devin Wolanick
 * @Version 1.0
 * 
 * Model for BlackJack
 */
public class BJmodel {
	
	private static int numberOfPlayers;
	private static int numberOfDecks;
	private Dealer myDealer;
	private Watcher myWatcher;
	private DebugWindow myDebug;
	private LuckyWindow myLucky;
	
	/**
	 * Creates A List of BlackJack Players
	 * @param numOfPlayers Number of Players
	 * @return A List Of BlackjackPlayers
	 */
	private ArrayList<BlackJackPlayer> createPlayers(int numOfPlayers) {
		ArrayList<BlackJackPlayer> playerList = new ArrayList<BlackJackPlayer>();
		for (int i=0; i<numOfPlayers; i++) {
			BlackJackPlayer myPlayer = new ManuPlayer();
			playerList.add(myPlayer);
		}
		return playerList;
	}
	
	/**
	 * Sets up Game options
	 * @param numPlayers Number of Players
	 * @param numDecks Number of Decks
	 */
	public void setUp(int[] optionList) {
		numberOfPlayers = optionList[2];
		numberOfDecks = optionList[3];
		ArrayList<BlackJackPlayer> playerList = createPlayers(numberOfPlayers);
		myWatcher = new Watcher();
		myDebug = new DebugWindow();
		myLucky = new LuckyWindow(numberOfPlayers);
		myDealer = new Dealer(numberOfDecks, optionList[0], playerList, myWatcher, myDebug);
		myDealer.setThresh(optionList[1]);
	}
	
	/**
	 * Deals the table
	 */
	public void dealTable() {
		myDealer.dealTable();
	}
	
	/**
	 * Returns All cards in play
	 * @return List Of Hands - Dealers Hand last
	 */
	public ArrayList<ArrayList<Card>> getTable() { 
		return myDealer.reportCards();
	}
	
	public ArrayList<ArrayList<Integer>> getValues() {
		return myDealer.reportValues();
	}
	
	/**
	 * Returns Games Dealer
	 * @return Games Dealer
	 */
	public Dealer getDealer() {
		return myDealer;
	}
	
	/**
	 * Returns Games Watcher
	 * @return Games Watcher
	 */
	public Watcher getWatcher() {
		return myWatcher;
	}
	
	/**
	 * Switches Debug Visibility
	 */
	public void switchDebug() {
		myDebug.switchVisible();
	}
	
	/**
	 * Switches Lucky Visibility
	 */
	public void switchLucky() {
		myLucky.switchVisible();
	}
	
	/**
	 * Exports Data
	 */
	public void exportData() {
		myWatcher.exportData();
	}
}
